package com.powerbank.common.client;

import com.powerbank.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Map;

/**
 * 支付中心服务客户端
 */
@FeignClient(name = "payment-center", path = "/payments", fallback = PaymentCenterClientFallback.class)
public interface PaymentCenterClient {

    /**
     * 获取用户钱包余额
     */
    @GetMapping("/wallets/{userId}/balance")
    Result<BigDecimal> getWalletBalance(@PathVariable("userId") Long userId);

    /**
     * 冻结用户钱包金额
     */
    @PostMapping("/wallets/freeze")
    Result<String> freezeAmount(@RequestBody Map<String, Object> freezeRequest);

    /**
     * 解冻用户钱包金额
     */
    @PostMapping("/wallets/unfreeze")
    Result<Void> unfreezeAmount(@RequestBody Map<String, Object> unfreezeRequest);

    /**
     * 扣除用户钱包金额
     */
    @PostMapping("/wallets/deduct")
    Result<Void> deductAmount(@RequestBody Map<String, Object> deductRequest);

    /**
     * 退款到用户钱包
     */
    @PostMapping("/wallets/refund")
    Result<Void> refundAmount(@RequestBody Map<String, Object> refundRequest);

    /**
     * 创建支付订单
     */
    @PostMapping("/orders/create")
    Result<Map<String, Object>> createPaymentOrder(@RequestBody Map<String, Object> paymentRequest);

    /**
     * 查询支付状态
     */
    @GetMapping("/orders/{paymentNo}/status")
    Result<Map<String, Object>> getPaymentStatus(@PathVariable("paymentNo") String paymentNo);

    /**
     * 取消支付订单
     */
    @PostMapping("/orders/{paymentNo}/cancel")
    Result<Void> cancelPaymentOrder(@PathVariable("paymentNo") String paymentNo);

    /**
     * 创建退款订单
     */
    @PostMapping("/refunds/create")
    Result<Map<String, Object>> createRefundOrder(@RequestBody Map<String, Object> refundRequest);

    /**
     * 查询退款状态
     */
    @GetMapping("/refunds/{refundNo}/status")
    Result<Map<String, Object>> getRefundStatus(@PathVariable("refundNo") String refundNo);

    /**
     * 获取用户钱包信息
     */
    @GetMapping("/wallets/{userId}")
    Result<Map<String, Object>> getWalletInfo(@PathVariable("userId") Long userId);

    /**
     * 充值到用户钱包
     */
    @PostMapping("/wallets/{userId}/recharge")
    Result<Void> rechargeWallet(@PathVariable("userId") Long userId, 
                               @RequestParam("amount") BigDecimal amount,
                               @RequestParam("paymentMethod") String paymentMethod);
}